/****************************************************************************
   Copyright 2013 Stacy Doss

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
****************************************************************************/

%{
#include "SpefParserBase.tab.h"

#include <iostream>

extern int line_number;
%}

%option noyywrap
 
%%
I                         { return INPUT; }

O                         { return OUTPUT; }

B                         { return BIDI; }

\*L                       { return LOAD; }

\*S                       { return SLEW; }

\*C                       { return COORD; }

\*D                       { return DRIVER; }

\*P                       { return PORT; }

\*I                       { return INTERNAL; }

\*V                       { return VCONF; }

\*D_NET                   { return DNET; }

\*CONN                    { return CONN; }

\*CAP                     { return CAP; }

\*RES                     { return RES; }

\*INDUCT                  { return INDUCT; }

\*END                     { return END; }

\*SPEF                    { yylval.s=strdup(yytext); return SPEF; }

\*DESIGN                  { yylval.s=strdup(yytext); return DESIGN; }

\*DATE                    { yylval.s=strdup(yytext); return DATE; }

\*VENDOR                  { yylval.s=strdup(yytext); return VENDOR; }

\*PROGRAM                 { yylval.s=strdup(yytext); return PROGRAM; }

\*VERSION                 { yylval.s=strdup(yytext); return VERSION; }

\*DESIGN_FLOW             { yylval.s=strdup(yytext); return DESIGN_FLOW; }

\*DIVIDER                 { yylval.s=strdup(yytext); return DIVIDER; }

\*DELIMITER               { yylval.s=strdup(yytext); return DELIMITER; }

\*BUS_DELIMITER           { yylval.s=strdup(yytext); return BUS_DELIMITER; }

\*T_UNIT                  { yylval.s=strdup(yytext); return T_UNIT; }

\*C_UNIT                  { yylval.s=strdup(yytext); return C_UNIT; }

\*R_UNIT                  { yylval.s=strdup(yytext); return R_UNIT; }

\*L_UNIT                  { yylval.s=strdup(yytext); return L_UNIT; }

\*NAME_MAP                { return NAMEMAP; }

\*PORTS                   { return PORTS; }

NS                        { yylval.s=strdup(yytext); return NS; }
PS                        { yylval.s=strdup(yytext); return PS; }
PF                        { yylval.s=strdup(yytext); return PF; }
FF                        { yylval.s=strdup(yytext); return FF; }
OHM                       { yylval.s=strdup(yytext); return OHM; }
KOHM                      { yylval.s=strdup(yytext); return KOHM; }
HENRY                     { yylval.s=strdup(yytext); return HENRY; }
MH                        { yylval.s=strdup(yytext); return MH; }
UH                        { yylval.s=strdup(yytext); return UH; }

\"[^\"]*\"                { yylval.s=strdup(yytext); return QSTRING; } 

[0-9]+                    { yylval.i=atoi(yytext);   return INT; }

[0-9]+\.[0-9]+            { yylval.f=atof(yytext);   return FLOAT; }

\[                        { yylval.s=strdup(yytext); return LEFTBRACKET; }
\]                        { yylval.s=strdup(yytext); return RIGHTBRACKET; }
\{                        { yylval.s=strdup(yytext); return LEFTBRACE; }
\}                        { yylval.s=strdup(yytext); return RIGHTBRACE; }
\(                        { yylval.s=strdup(yytext); return LEFTPAREN; }
\)                        { yylval.s=strdup(yytext); return RIGHTPAREN; }
\<                        { yylval.s=strdup(yytext); return LEFTANGLE; }
\>                        { yylval.s=strdup(yytext); return RIGHTANGLE; }

\.                        { yylval.s=strdup(yytext); return PERIOD; }

\:                        { yylval.s=strdup(yytext); return COLON; }

\/                        { yylval.s=strdup(yytext); return BACKSLASH; }

\|                        { yylval.s=strdup(yytext); return PIPE; }

\*[0-9]+                  { yylval.s=strdup(yytext); return INDEX; }

[_a-zA-Z0-9]*             { yylval.s=strdup(yytext); return NAME; }

[ \t\r]+                  /* eat up whitespace */

[\n]                      { line_number++; }

"/*""/"*([^*/]|[^*]"/"|"*"[^/])*"*"*"*/"  /* eat comments */

%%
